package String.StringDemo;

public class 数组变字符串 {
    public static void main(String[] args) {
        int[] arr={1,2,3};
        System.out.println(arrToString(arr));
    }

    public static String arrToString(int[] arr) {
        String result = "[";
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                result += arr[i];
            } else {
                result += arr[i] + ", ";
            }

        }
        result += "]";
        return result;
    }
}
